﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace BaseTypesControlLib.Controls
{
    public class SeparatorFieldControl:FieldControl
    {
        public SeparatorFieldControl()
        {
            DefaultStyleKey = typeof(SeparatorFieldControl);
        }
        protected override Size MeasureOverride(Size constraint)
        {
            Size sz = new Size();
            if (IsHorizontal)
            {
                sz.Width = constraint.Width;
                sz.Height = 3;
            }
            else
            {
                sz.Height = constraint.Height;
                sz.Width = 3;
            }
            return sz;
        }

        static SeparatorFieldControl()
        {
            FrameworkPropertyMetadata fdm = new FrameworkPropertyMetadata(true, 
                FrameworkPropertyMetadataOptions.AffectsMeasure | 
                FrameworkPropertyMetadataOptions.AffectsArrange);
            IsHorizontalProperty = DependencyProperty.Register("IsHorizontal", 
                typeof(bool), typeof(SeparatorFieldControl), fdm);
        }

        public bool IsHorizontal
        {
            get { return (bool)GetValue(IsHorizontalProperty); }
            set { SetValue(IsHorizontalProperty, value); }
        }
        public static readonly DependencyProperty IsHorizontalProperty;

        
    }
}
